//
//  QKTabbarController.m
//  Gigle
//
//  Created by 丁乾坤 on 16/9/9.
//  Copyright © 2016年 丁乾坤. All rights reserved.
//

#import "QKTabbarController.h"
#import "QKEssenceController.h"
#import "QKNewController.h"
#import "QKFocusController.h"
#import "QKMeController.h"
#import "QKNavigationController.h"

@interface QKTabbarController ()<UITabBarControllerDelegate>

@end

@implementation QKTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self _initViewController];
    [self addModelPlusButton];
    
}

//中间加号按钮
- (void)addModelPlusButton{
    CGFloat WINDOW_HEIGHT = self.view.frame.size.height;
    CGFloat PLUSVIEW_HEIGHT = self.tabBar.frame.size.height;
    CGFloat PLUSIVIEW_WIDTH = self.view.frame.size.width / 5;
    CGFloat MAXPLUSVIEW_Y = WINDOW_HEIGHT - PLUSVIEW_HEIGHT;
    CGFloat MAXPLUSBUTTON_Y = 5.f;
    CGFloat PLUSBUTON_WIDTH = PLUSVIEW_HEIGHT - MAXPLUSBUTTON_Y * 2;
    CGFloat PLUSBUTON_HEIGHT = PLUSBUTON_WIDTH;
    
    //遮罩层视图  用于遮挡原本的tabbarItem
    UIView *modalView = [[UIView alloc] initWithFrame:CGRectMake(PLUSIVIEW_WIDTH * 2, MAXPLUSVIEW_Y, PLUSIVIEW_WIDTH, PLUSVIEW_HEIGHT)];
    [self.view addSubview:modalView];
    
    //自定义按钮
    UIButton *plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
    plusButton.frame = CGRectMake(PLUSIVIEW_WIDTH * 2 + (PLUSIVIEW_WIDTH - PLUSBUTON_WIDTH) / 2, MAXPLUSVIEW_Y + MAXPLUSBUTTON_Y, PLUSBUTON_WIDTH, PLUSBUTON_HEIGHT);
    [plusButton setTitle:@"+" forState:UIControlStateNormal];
    [plusButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    plusButton.titleLabel.font = [UIFont boldSystemFontOfSize:30];
    plusButton.backgroundColor = [UIColor redColor];
    plusButton.layer.cornerRadius = 19.5f;
    [self.view addSubview:plusButton];
}

- (void)_initViewController{
    //设置视图的背景色
    self.view.backgroundColor = [UIColor whiteColor];
    
    //精华视图控制器
    QKEssenceController *essenceVC = [[QKEssenceController alloc] init];
    QKNavigationController *essenceNav = [[QKNavigationController alloc] initWithRootViewController:essenceVC];
    essenceVC.title = @"精选";
    essenceVC.navigationItem.title = @"百思不得姐";
    [self addChildViewController:essenceNav];
    
    
     //最新视图控制器
    QKNewController *newVC = [[QKNewController alloc] init];
    QKNavigationController *newNav = [[QKNavigationController alloc] initWithRootViewController:newVC];
    newVC.title = @"最新";
    newVC.navigationItem.title = @"百思不得姐";
    [self addChildViewController:newNav];

    
    //空视图控制器
    QKFocusController *emtyVC = [[QKFocusController alloc] init];
    QKNavigationController *emtyNav = [[QKNavigationController alloc] initWithRootViewController:emtyVC];
    [self addChildViewController:emtyNav];
    
    //关注视图控制器
    QKFocusController *focusVC = [[QKFocusController alloc] init];
    QKNavigationController *focusNav = [[QKNavigationController alloc] initWithRootViewController:focusVC];
    focusVC.title = @"关注";
    [self addChildViewController:focusNav];
    
    //我视图控制器
    QKMeController *meVC = [[QKMeController alloc] init];
    QKNavigationController *meNav = [[QKNavigationController alloc] initWithRootViewController:meVC];
    meVC.title = @"我";
    meVC.navigationItem.title = @"我的";
    [self addChildViewController:meNav];
    
}


@end
